package com.kust.smarthome.web.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.kust.smarthome.web.model.DeviceState;
import com.kust.smarthome.web.model.Lamp;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author iAuzre
 * @since 2021-06-28
 */
@Repository
public interface LampMapper extends BaseMapper<Lamp> {

    @Select("select id,is_update,type_id,device_id,operation from device_state where device_id=#{deviceId} and type_id=#{typeId} and is_update=0")
    List<DeviceState> getOperationList(Integer deviceId, Integer typeId);

    @Update("update device_state set is_update=1 where device_id=#{id}")
    boolean changeUpdate(Integer id);
}
